#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import psutil
import os
def my_memory_g():
    #获取当前运行的pid
    p1=psutil.Process(os.getpid()) 
    mem = psutil.virtual_memory()
    total_g = mem.total/1024/1024/1024
    p1_g = p1.memory_percent() * total_g * 0.01
    
    print('当前进程占用内存/总内存：%d/%d'%(p1_g, total_g))
#def my_memory_g():
#    #获取当前运行的pid
#    p1=psutil.Process(os.getpid())
#    return "memory percent: %.2f%%" % (p1.memory_percent())
# %%
if __name__ == '__main__':
    my_memory_g()
